﻿#include "AddUserObject.h"
#include "Application.h"
#include "UserObject.h"

void AddUserObjectAction::Execute()
{
  std::string section = "UserObjects/";
  if (!_parser.ExistSection(section))
    return;

  _parser.SetPrefix(section);

  Configuration cfg;
  cfg.Add<Application*>("_app", &_app);
  cfg.Add<Parser*>("_parser", &_parser);
  auto type = cfg.Get<std::string>("type");
  _app.AddUserObject(ObjectFactory::Make<UserObject>(type, cfg));

  console::Success("AddUserObject");
}